<template>
    <!-- 添加或修改到货付款对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-tabs v-model="activeName" class="detail-tab" type="card">
                <el-tab-pane label="基本信息" name="first">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="删除标志" prop="delFlag">
                                <el-input v-model="form.delFlag" placeholder="请输入删除标志"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="备注" prop="remark">
                                <el-input v-model="form.remark" placeholder="请输入备注"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="税率" prop="tax">
                                <el-input v-model="form.tax" placeholder="请输入税率"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="打款金额" prop="money">
                                <el-input v-model="form.money" placeholder="请输入打款金额"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="剩余欠款" prop="shengyu">
                                <el-input v-model="form.shengyu" placeholder="请输入剩余欠款"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="统一社会信用代码" prop="code">
                                <el-input v-model="form.code" placeholder="请输入统一社会信用代码"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="总数量" prop="counts">
                                <el-input v-model="form.counts" placeholder="请输入总数量"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="过磅吨位" prop="dunwei">
                                <el-input v-model="form.dunwei" placeholder="请输入过磅吨位"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="供应商id" prop="supplierId">
                                <el-input v-model="form.supplierId" placeholder="请输入供应商id"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="供应商名称" prop="supplierName">
                                <el-input v-model="form.supplierName" placeholder="请输入供应商名称"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="审核状态" prop="state">
                                <el-input v-model="form.state" placeholder="请输入审核状态"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="开户行行号" prop="hanghao">
                                <el-input v-model="form.hanghao" placeholder="请输入开户行行号"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="银行账号" prop="zhanghao">
                                <el-input v-model="form.zhanghao" placeholder="请输入银行账号"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="开户行" prop="kaihuhang">
                                <el-input v-model="form.kaihuhang" placeholder="请输入开户行"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="开票金额" prop="kaipiao">
                                <el-input v-model="form.kaipiao" placeholder="请输入开票金额"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="开票文件">
                                <file-upload v-model="form.kpfile"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="过磅单文件" prop="guobangdan">
                                <el-input v-model="form.guobangdan" type="textarea" placeholder="请输入内容"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="直发货回执单" prop="zhifahuo">
                                <el-input v-model="form.zhifahuo" type="textarea" placeholder="请输入内容"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="打款人" prop="ddSongpeople">
                                <el-input v-model="form.ddSongpeople" placeholder="请输入打款人"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="打款记录截图">
                                <file-upload v-model="form.ddSongfile"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="打款日期" prop="ddDatepeople">
                                <el-date-picker clearable
                                                v-model="form.ddDatepeople"
                                                type="date"
                                                value-format="yyyy-MM-dd"
                                                placeholder="请选择打款日期">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="打款编号" prop="nos">
                                <el-input v-model="form.nos" placeholder="请输入打款编号"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="到货id" prop="daohuoid">
                                <el-input v-model="form.daohuoid" placeholder="请输入到货id"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="到货编号" prop="daohuono">
                                <el-input v-model="form.daohuono" placeholder="请输入到货编号"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采购id" prop="caigouid">
                                <el-input v-model="form.caigouid" placeholder="请输入采购id"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采购编号" prop="caigouno">
                                <el-input v-model="form.caigouno" placeholder="请输入采购编号"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="到货日期" prop="daohuodate">
                                <el-date-picker clearable
                                                v-model="form.daohuodate"
                                                type="date"
                                                value-format="yyyy-MM-dd"
                                                placeholder="请选择到货日期">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="请购id" prop="qinggouid">
                                <el-input v-model="form.qinggouid" placeholder="请输入请购id"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="请购编号" prop="qinggouno">
                                <el-input v-model="form.qinggouno" placeholder="请输入请购编号"/>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
            </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import { addAction, getById, updateAction } from '@/api/manage';
    import moment from 'moment';

    export default {
        name: "LvFukuanForm",
        data() {
            return {
                // 遮罩层
                loading: true,
                activeName: "first",
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                },
                url: {
                    getById:'/lvFukuan/lvFukuan/',
                    add:'/lvFukuan/lvFukuan/add',
                    edit:'/lvFukuan/lvFukuan/edit',
                },
            };
        },
        created() {

        },
        methods: {
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
            id: null,
            delFlag: null,
            createBy: null,
            createTime: null,
            updateBy: null,
            updateTime: null,
            remark: null,
            ywType: null,
            tax: null,
            money: null,
            shengyu: null,
            code: null,
            counts: null,
            dunwei: null,
            supplierId: null,
            supplierName: null,
            state: null,
            hanghao: null,
            zhanghao: null,
            kaihuhang: null,
            kaipiao: null,
            kpfile: null,
            guobangdan: null,
            zhifahuo: null,
            ddSongpeople: null,
            ddSongfile: null,
            ddDatepeople: null,
            nos: null,
            daohuoid: null,
            daohuono: null,
            caigouid: null,
            caigouno: null,
            daohuodate: null,
            qinggouid: null,
            qinggouno: null
                };
                this.resetForm("form");
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加到货付款";
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids;
                getById(this.url.getById, id).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改到货付款";
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.id != null) {
                            updateAction(this.url.edit, this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.$emit('ok');
                            });
                        } else {
                            addAction(this.url.add, this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.$emit('ok');
                            });
                        }
                    }
                });
            },
        }
    };
</script>
